uDebugger Assignment

Overview

Data aborts and prefetch aborts are the most common problems that can block people developing embedded code. The error is easy to make but hard to debug.

One of the reason it’s hard to debug is because after the exception occurs it can be hard to figure out the line of code that caused the exception.

In this assignment we will write our own little micro debugger.

Not only will the exercise be instructive, but it will also save time later on. It will make it easier to find source of exceptions and will provide a small test bed that can be expanded to be even more useful as the course goes on.

Objective

  • Write one or two routines that will handle Data Abort and Prefetch Abort exceptions.
  • Print the type of exception and the address it occured at to the serial port.

Concept

Data or Prefetch exception occurs. Each jumps through its vector to a respective handler. The handler save the context and sets R0 with a flag indicating the type of exception.

The handler then reads original link register value, adjusts it correctly and writes to r1. Then it calls a print routine the prints out the type of exception and the memory location it occured at.

Steps

  • Replace PAbortHandler and DAbortHandler with your code
  • Each handler should do the following:
    • Adjust LR correctly for the type of exception
    • Save the context to the stack
    • Set R0 with 0x01 for data abort, 0x02 for prefetch abort
    • Set R1 with address that cause the abort
    • Call print function
  • The print function is a C function and takes to ints.
    • Prints “Data Abort” plus address for type = 0x01
    • Prints “Prefetch Abort” plus address for type = 0x02

The function should have this signature:

void abortPrint(UINT type, UINT address)
  • Write a test function that will cause an abort
  • Compare the printed address with the code list file. Do they agree?

Challenge

Write a test that lets you test both exceptions one after the other.

To do this you will need to either return from the exception handler or continue at a different location calling a different function.

To show it works, loop through both exceptions 10 times, printing a count each time and exit cleanly, that is by returning from main().

Table Of Contents

Previous topic

Translation Lookaside Buffer

Next topic

Context Switch Assignment

This Page